﻿<Window
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:TwitterViewer"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2006"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"
    xmlns:Microsoft_Windows_Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero"
    x:Class="TwitterViewer.MainWindow"
    Title="WPF Twitter" Width="640" Height="480" MinHeight="160" MinWidth="320"
    >

  <Window.Resources>
    <Style TargetType="{x:Type TextBlock}">
      <Setter Property="FontSize" Value="14"/>
      <Setter Property="FontFamily" Value="Calibri"/>
    </Style>
    <Style TargetType="GridViewColumnHeader">
      <Setter Property="Visibility" Value="Collapsed" />
    </Style>

    <local:CharRemainingValueConverter x:Key="CharRemainingConverter"/>
    
  	<LinearGradientBrush x:Key="TextBoxBorder" MappingMode="Absolute" EndPoint="0,20" StartPoint="0,0">
  		<GradientStop Color="#ABADB3" Offset="0.05"/>
  		<GradientStop Color="#E2E3EA" Offset="0.07"/>
  		<GradientStop Color="#E3E9EF" Offset="1"/>
  	</LinearGradientBrush>
    
  	<Style x:Key="TweetTextBoxStyle" BasedOn="{x:Null}" TargetType="{x:Type TextBox}">
  		<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
  		<Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"/>
   		<Setter Property="Padding" Value="1"/>
  		<Setter Property="AllowDrop" Value="true"/>
  		<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
  		<Setter Property="Template">
  			<Setter.Value>
  				<ControlTemplate TargetType="{x:Type TextBox}">
  					<Microsoft_Windows_Themes:ListBoxChrome SnapsToDevicePixels="true" x:Name="Bd" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" >
  						<ScrollViewer SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" x:Name="PART_ContentHost"/>
  					</Microsoft_Windows_Themes:ListBoxChrome>
  				</ControlTemplate>
  			</Setter.Value>
  		</Setter>
  	</Style>
  </Window.Resources>

	<Grid x:Name="MainGrid">
		<Grid.RowDefinitions>
			<RowDefinition Height="40"/>
			<RowDefinition Height="80"/>
			<RowDefinition Height="*"/>
			<RowDefinition Height="65"/>
      <RowDefinition Height="20"/>
    </Grid.RowDefinitions>
		<DockPanel LastChildFill="False" Margin="20,10,20,10">
			<Button x:Name="RefreshButton" Content="Refresh" Click="RefreshButton_Click" HorizontalAlignment="Right" Width="50" DockPanel.Dock="Right" FontSize="11"/>
			<Button x:Name="LoginButton" Content="Login" Click="LoginButton_Click" Width="50" Margin="0,0,10,0" DockPanel.Dock="Right" FontSize="11"/>
			<TextBlock x:Name="header" VerticalAlignment="Center" FontFamily="Calibri" FontSize="18" FontWeight="Bold" Text="WPF Twitter" TextWrapping="Wrap">
				<TextBlock.BitmapEffect>
					<OuterGlowBitmapEffect GlowColor="#FFC8DFE0" GlowSize="8"/>
				</TextBlock.BitmapEffect>
			</TextBlock>
		</DockPanel>
		<Grid MaxHeight="62.283" MinHeight="62.283" d:LayoutOverrides="GridBox" Margin="20,42.18,20,8.88" Grid.RowSpan="2">

			<Border Background="#BFB6D4D6" BorderBrush="#FF0E8084" BorderThickness="1,1,1,1" CornerRadius="5,5,5,5" Margin="80,1.15,0,1.033">
				<DockPanel >
					<TextBlock Text="{Binding Path=User.FullName, Mode=Default, FallbackValue=Username}" FontWeight="Bold" DockPanel.Dock="Top" Margin="5,5,0,0" />
          <TextBox Text="{Binding Path=Text, Mode=Default, FallbackValue=Tweet text}" TextWrapping="Wrap" HorizontalAlignment="Stretch" Margin="0,0,0,0" DockPanel.Dock="Top" Height="35" Style="{DynamicResource TweetTextBoxStyle}" Background="{x:Null}" BorderBrush="{x:Null}" IsReadOnly="True" x:Name="TweetTextBox" Visibility="Collapsed" TextChanged="TweetTextBox_TextChanged"/>
          <TextBlock Text="{Binding Path=Text, Mode=Default, FallbackValue=Tweet text}" TextWrapping="Wrap" HorizontalAlignment="Stretch" Margin="5,0,5,0" DockPanel.Dock="Top" Height="35" x:Name="TweetTextBlock" />
				</DockPanel>
			</Border>
			<Path Fill="#BFB6D4D6" Stretch="Fill" Stroke="#FF0E8084" Width="24.892" Height="14" Data="M100.29963,65.084419 L76.407528,58.771146 100.29929,52.083162" HorizontalAlignment="Left" Margin="56.441,0,0,9.116" VerticalAlignment="Bottom"/>

			<StackPanel HorizontalAlignment="Left" Width="52">
				<Border BorderBrush="#FF000000" BorderThickness="1,1,1,0" x:Name="ImageBorder" Height="48">
					<Image Width="48" Height="48" Source="{Binding Path=User.ImageUrl, Mode=Default}"/>
				</Border>

				<Border BorderBrush="#FF000000" BorderThickness="1,0,1,1">
					<TextBlock d:LayoutOverrides="VerticalAlignment, Height"  Width="48" Background="#BFB6D4D6" FontSize="10" Text="{Binding Path=User.ScreenName, Mode=Default, FallbackValue=ScreenName}" TextAlignment="Center" TextTrimming="CharacterEllipsis" TextWrapping="NoWrap"/>
				</Border>
			</StackPanel>
		</Grid>
		<Grid Margin="20,0,20,10" VerticalAlignment="Stretch" Grid.Row="2">
			<ListView ItemsSource="{Binding Mode=OneWay}" IsSynchronizedWithCurrentItem="True" ScrollViewer.HorizontalScrollBarVisibility="Disabled" x:Name="TweetsListView">
				<ListView.View>
					<GridView AllowsColumnReorder="False" >

						<GridViewColumn  Width="Auto">
							<GridViewColumn.CellTemplate>
								<DataTemplate>
									<StackPanel Orientation="Horizontal">
										<Image Width="15" Height="15" Source="{Binding Path=User.ImageUrl, Mode=Default}" Margin="5,0,5,0"/>
										<TextBlock Text="{Binding Path=User.ScreenName}" />
									</StackPanel>
								</DataTemplate>
							</GridViewColumn.CellTemplate>
						</GridViewColumn>

						<GridViewColumn Width="315">
							<GridViewColumn.CellTemplate>
								<DataTemplate>
									<TextBlock Text="{Binding Path=Text}" Width="Auto" TextTrimming="CharacterEllipsis" TextWrapping="NoWrap"/>
								</DataTemplate>
							</GridViewColumn.CellTemplate>
						</GridViewColumn>

						<GridViewColumn Header="RelativeTime" Width="Auto">
							<GridViewColumn.CellTemplate>
								<DataTemplate>
									<TextBlock Text="{Binding Path=RelativeTime}" />
								</DataTemplate>
							</GridViewColumn.CellTemplate>
						</GridViewColumn>
					</GridView>
				</ListView.View>
			</ListView>
		</Grid>
		<Border CornerRadius="5,5,5,5" Height="57" Margin="20,0,20,0" VerticalAlignment="Top" Grid.Row="3" >
			<Grid Height="47">
				<StackPanel Orientation="Horizontal" VerticalAlignment="Top" Height="13.427">
					<TextBlock HorizontalAlignment="Left" Text="{Binding Path=Text.Length, Converter={StaticResource CharRemainingConverter}, ElementName=AddTweetTextBox, Mode=Default}" FontSize="11" >
						<TextBlock.BitmapEffect>
							<OuterGlowBitmapEffect GlowColor="#FFC8DFE0"/>
						</TextBlock.BitmapEffect>
					</TextBlock>
					<TextBlock HorizontalAlignment="Left" Text=" Character Remaining" FontSize="11">
						<TextBlock.BitmapEffect>
							<OuterGlowBitmapEffect GlowColor="#FFC8DFE0"/>
						</TextBlock.BitmapEffect>
					</TextBlock>
				</StackPanel>
				<TextBox Text="" TextWrapping="Wrap" x:Name="AddTweetTextBox" MaxLength="140" Margin="0,13.427,84,0" SpellCheck.IsEnabled="True"/>
				<Button Width="70" Content="Add" x:Name="AddButton" Click="AddButton_Click" IsDefault="True" HorizontalAlignment="Right" VerticalAlignment="Bottom"/>
			</Grid>
		</Border>
    <Border Grid.Row="4" Margin="20,0,20,0" Background="#BFB6D4D6" CornerRadius="5,5,5,5">
      <StatusBar Background="{x:Null}">
        <StatusBarItem Margin="5,0,0,0">
          <TextBlock x:Name="StatusTextBlock" FontSize="12"/>
        </StatusBarItem>
      </StatusBar>
    </Border>
  </Grid>
</Window>
